package com.changyou.kf.core.exception;

/**
 * 全局错误码
 *
 * @author wujun
 * @since 2017/02/16
 */
public enum GlobalErrorCode implements ErrorCode {

    OK(0, "ok"),
    ERROR(1, "error"),

    BAD_REQUEST(400, "Bad Request"),
    UNAUTHORIZED(401, "Unauthorized"),
    FORBIDDEN(403, "Forbidden"),
    NOT_FOUND(404, "Not Found"),
    METHOD_NOT_ALLOWED(405, "Method Not Allowed"),
    INTERNAL_SERVER_ERROR(500, "Internal Server Error"),

    INVALID_PARAM(1001, "invalid param"),
    INVALID_CONTENT_TYPE(1001, "Invalid ContentType"),

    PARAMS_VALID_ERROR(1011, "params valid error"),

    DB_ERROR(1101, "db error"),
    DB_FIELD_LENGTH_LIMIT_ERROR(1102, "db field length limit"),

    UPLOAD_FILE_ERROR(1201, "upload file error"),
    UPLOAD_FILE_EMPTY(1202, "upload file empty"),
    UPLOAD_FILE_MAX_SIZE_ERROR(1203, "upload file size limit max"),
    UPLOAD_FORMAT_ERROR(1204, "upload file format not support"),
    UPLOAD_FORMAT_IMAGE_ERROR(1205, "upload file allow image"),
    UPLOAD_FORMAT_TXT_ERROR(1206, "upload file allow txt"),
    UPLOAD_TXT_CONTENT_LIMIT_ERROR(1207, "上传txt文件行数超过限制"),
    UPLOAD_IMAGE_FORMAT_ERROR(2004, "只允许上传图片"),
    UPLOAD_NOT_ALLOW_EXTENSION(2005, "当前文件格式不允许上传"),
    UPLOAD_EX_ERROR(1209, "upload file ex"),

    OSS_UPLOAD_FILE_FAILED(1211, "上传OSS文件失败"),
    OSS_FOLDER_NAME_INVALID(1212, "创建OSS文件夹名字非法"),

    DANGEROUS_INPUT(1301, "不安全的输入"),
    PARSE_JOSN_BODY_ERROR(1302, "json format error"),
    JSON_ERROR(1303, "json error"),

    RPC_ERROR(1401, "rpc error"),
    FREQUENTLY_ERROR(1402, "访问太频繁，请稍后再试"),

    ACCESS_LIMIT_REACHED(1432, "小主手速太快，等一下再点嘛~"),

    AUTHORIZATION_MISSING(2001, "缺少Authorization参数"),
    AUTHORIZATION_INVALID(2002, "无效的Authorization"),
    AUTHORIZATION_EXPIRED(2003, "登录已过期，请重新登录"),
    AUTHORIZATION_UNAUTHORIZED(2004, "访问资源未授权"),
    AUTHORIZATION_FORCE_ONLINE(2005, "登录已被强制下线"),
    AUTHORIZATION_NOT_LOGIN(2006, "用户未登录"),

    ;

    GlobalErrorCode(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

     private final int code;

    private String msg;

    @Override
    public int getCode() {
        return this.code;
    }

    @Override
    public String getMsg() {
        return this.msg;
    }

    @Override
    public void setMsg(String msg) {
        this.msg = msg;
    }
}
